﻿// upload service for uploading images
angular.module('app.common').service('uploadService', ['$http',
	function ($http) {
		'use strict';
		// upload image as form data
		var upload = function (formData) {
			return $http.post('/api/Image', formData, {
				withCredentials: false,
				headers: { 'Content-Type': undefined }, // content-type will be determined automatically
				transformRequest: angular.identity
			}).success(function (data, status, headers, config) {
				// Do something
			}).error(function (data, status, headers, config) {
				// Do something
			});
		},
		svc = {
			upload: upload
		};

		return svc;
	}]);